home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBGRX100.ARJ / POLYTEST.C < prev    next >
Text File  |  1992-04-10  |  2KB  |  69 lines

  1. /** 
  2.  ** POLYTEST.C 
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "test.h"
  25. #include <string.h>
  26.  
  27. static int red;
  28.  
  29. static void testpoly(int n,int points[][2])
  30. {
  31.     GrClearScreen(GrBlack());
  32.     GrSetClipBox(100,100,700,500);
  33.     GrFilledPolygon(n,points,red);
  34.     GrSetClipBox(0,0,GrMaxX(),GrMaxY());
  35.     GrBox(99,99,701,501,GrWhite() | GrXOR);
  36.     GrPolygon(n,points,GrWhite() | GrXOR);
  37.     getkey();
  38. }
  39.  
  40. TESTFUNC(ptest)
  41. {
  42.     char buff[300];
  43.     int  pts[300][2];
  44.     int  ii,collect;
  45.     FILE *fp;
  46.  
  47.     fp = fopen("polytest.dat","r");
  48.     if(fp == NULL) return;
  49.     collect = 0;
  50.     red = GrAllocColor(255,0,0);
  51.     GrSetColor((red ^ GrWhite()),0,50,255);
  52.     while(fgets(buff,299,fp) != NULL) {
  53.         if(!collect) {
  54.         if(strncmp(buff,"begin",5) == 0) {
  55.             collect = 1;
  56.             ii = 0;
  57.         }
  58.         continue;
  59.         }
  60.         if(strncmp(buff,"end",3) == 0) {
  61.         testpoly(ii,pts);
  62.         collect = 0;
  63.         continue;
  64.         }
  65.         if(sscanf(buff,"%d %d",&pts[ii][0],&pts[ii][1]) == 2) ii++;
  66.     }
  67. }
  68.  
  69.